package model.service;


import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;


public class ServiceOrder {
	
	private int serviceOrder;
	private SoStatusType soStatusType;
	private Employee createdBy;
	private ServiceRequest serviceRequest;
	private Employee updatedBy;
	private Timestamp created;
	private Timestamp updated;
	private Timestamp statusChanged;
	private Employee statusChangedBy;
	private float priceTotal;
	private String note;
	private List<ServiceAction> serviceActions;
	private List<ServicePart> serviceParts;
	private List<ServiceDevice> serviceDevices;
	
	
	public List<ServiceAction> getServiceActions() {
		return serviceActions;
	}

	public ServiceOrder() {
		this.serviceActions = new ArrayList<ServiceAction>();
		this.setServiceParts(new ArrayList<ServicePart>());
		this.setServiceDevices(new ArrayList<ServiceDevice>());
	}
	
	
	public ServiceOrder(int service_order_id) {
		this();
		this.serviceOrder = service_order_id;
	}

	public ServiceOrder(int id, ServiceRequest serviceRequest) {
		this(id);
		this.serviceRequest = serviceRequest;
	}

	public int getServiceOrder() {
		return serviceOrder;
	}
	public void setServiceOrder(int serviceOrder) {
		this.serviceOrder = serviceOrder;
	}
	public ServiceRequest getServiceRequest() {
		return serviceRequest;
	}
	public void setServiceRequest(ServiceRequest serviceRequest) {
		this.serviceRequest = serviceRequest;
	}
	public Timestamp getCreated() {
		return created;
	}
	public void setCreated(Timestamp created) {
		this.created = created;
	}
	public Timestamp getUpdated() {
		return updated;
	}
	public void setUpdated(Timestamp updated) {
		this.updated = updated;
	}
	public Timestamp getStatusChanged() {
		return statusChanged;
	}
	public void setStatusChanged(Timestamp statusChanged) {
		this.statusChanged = statusChanged;
	}
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		this.note = note;
	}	
	public void addServiceAction(ServiceAction serviceAction){
		this.serviceActions.add(serviceAction);
	}

	public void setCreatedBy(Employee createdBy) {
		this.createdBy = createdBy;
	}

	public Employee getCreatedBy() {
		return createdBy;
	}

	public void setUpdatedBy(Employee updatedBy) {
		this.updatedBy = updatedBy;
	}

	public Employee getUpdatedBy() {
		return updatedBy;
	}

	public void setStatusChangedBy(Employee statusChangedBy) {
		this.statusChangedBy = statusChangedBy;
	}

	public Employee getStatusChangedBy() {
		return statusChangedBy;
	}

	public void setServiceParts(List<ServicePart> serviceParts) {
		this.serviceParts = serviceParts;
	}

	public List<ServicePart> getServiceParts() {
		return serviceParts;
	}

	public void setServiceDevices(List<ServiceDevice> serviceDevices) {
		this.serviceDevices = serviceDevices;
	}

	public List<ServiceDevice> getServiceDevices() {
		return serviceDevices;
	}
	public void setServiceActions(List<ServiceAction> serviceActions) {
		this.serviceActions = serviceActions;
	}

	public void setSoStatusType(SoStatusType soStatusType) {
		this.soStatusType = soStatusType;
	}

	public SoStatusType getSoStatusType() {
		return soStatusType;
	}

	public void setPriceTotal(float priceTotal) {
		this.priceTotal = priceTotal;
	}

	public float getPriceTotal() {
		return priceTotal;
	}

	public float getCalculatePriceTotal() {
		float _return = 0;
		for (ServiceAction serviceAction : serviceActions) {
			_return += serviceAction.getPrice()*serviceAction.getServiceAmount();
		}
		
		for (ServicePart servicePart : serviceParts) {
			_return += servicePart.getPartPrice()*servicePart.getPartCount();
		}
		return _return;
	}
}
